<%--
  Created by IntelliJ IDEA.
  User: teacher
  Date: 2022/12/13
  Time: 10:45
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>四大作用域</title>
</head>
<body>
<%
    // 模拟存储数据
    pageContext.setAttribute("msg","Hello pageContext");
    request.setAttribute("msg","Hello request");
    session.setAttribute("msg","Hello session");
    application.setAttribute("msg","Hello application");
%>
<h1>当前页面</h1>
pageContext:<%=pageContext.getAttribute("msg")%><br>
request:<%=request.getAttribute("msg")%><br>
session:<%=session.getAttribute("msg")%><br>
application:<%=application.getAttribute("msg")%><br>
<%
    // 转发
    // 转发之后,pageContext数据丢失
    // request.getRequestDispatcher("/jsp/scope2.jsp").forward(request,response);
    // 重定向
    // 重定向之后,request数据丢失
    response.sendRedirect(request.getContextPath()+"/jsp/scope2.jsp");
    // 关闭浏览器重新访问第二个页面时,session数据丢失
    // 重启服务器之后,重新访问第二个页面时,application数据丢失
%>
</body>
</html>
